'use strict';
angular.module('clientApp')
.controller('supprimerHotelModalController', function ($scope, $modalInstance, hotel, hotelAPI, ngToast) {
	$scope.hotel = hotel;
	
	$scope.ok = function () {
		hotelAPI.remove(hotel.id)
		.success(function() {
			ngToast.create({
				content: 'L\'hôtel <b>' + hotel.name + '</b> a bien été supprimé',
				className: 'success'
			});
			$modalInstance.close(hotel);
    	})
    	.error(function() {
			ngToast.create({
				content: 'Erreur de communication avec le serveur',
				className: 'danger'
			});
			$modalInstance.close();
		});
	};

	$scope.cancel = function () {
		$modalInstance.dismiss('cancel');
	};
});
